<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01_字符串形式的ref</title>
</head>

<body>
    <div id="app"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script src="../js/prop-types.js"></script>

    <script type="text/babel">
        class MyComponent extends React.Component{
            // 点击按钮触发
            showData1 = ()=>{
                // 通过使用 this.refs.input1 可以获取使用 ref 声明的对应的元素DOM
                // 这里获取到DOM是真实DOM，所以可以使用DOM上面的各种属性和方法
                const {input1} = this.refs
                alert(input1.value)
            }
            render(){
                return (
                    <div>
                        <input ref="input1" placeholder="点击按钮弹出信息"/>
                        <button onClick={this.showData1}>显示左侧信息</button>
                        <input placeholder="离焦点触发"/>
                    </div>
                )
            }
        }
        ReactDOM.render(<MyComponent/>,document.getElementById("app"))
    </script>
</body>

</html>